<?php
date_default_timezone_set("Asia/Shanghai");
$conn_args = array(
    'host' => 'localhost',
    'port' => 5672,
    'login' => 'admin',
    'password' => 'admin2021',
    'vhost' => 'why'
); 
$ex_name = 'test_exchange';
$route = 'why.two';
$conn = new AMQPConnection($conn_args);
if(!$conn->connect())
{
    die("connect error");
}
$channel = new AMQPChannel($conn);
$exchange = new AMQPExchange($channel);
$exchange->setName($ex_name);
$exchange->setType('topic');
$exchange->declareExchange();
$message = 'test success two '.time();
echo date('Y-m-d H:i:s', time()) .':' . $exchange->publish($message, $route) . "\n";
$conn->disconnect();  